// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()
const db = cloud.database();
const _ = db.command;
// 云函数入口函数
exports.main = async (event, context) => {
  const openid = cloud.getWXContext().OPENID
  var {count} = event
  var _updateTime = Date.now();
            var rescount = await db.collection("jf_salecard").where({
                openid,
            }).get()
            var cc = rescount.data[0].count//有卡券
            if(cc)
            {
                return await db.collection("jf_salecard").where({
                    openid,
                  }).update({
                    data:{
                        _updateTime,
                        count,
                    }
                  })
            }
            else{
                    return false
            }
        
    

}